In [1]:
%load_ext autoreload
%autoreload 2
%aimport vector
%aimport line

In [2]:
from vector import *

Quiz: Coding Function for Lines


In [7]:
from line import *

l1 = Line(Vector([4.046, 2.836]), 1.21)
l2 = Line(Vector([10.115, 7.09]), 3.025)
print l1.intersection_with(l2)
print 'Same?', l1 == l2

l1 = Line(Vector([7.204, 3.182]), 8.68)
l2 = Line(Vector([8.172, 4.114]), 9.883)
print l1.intersection_with(l2)

l1 = Line(Vector([1.182, 5.562]), 6.744)
l2 = Line(Vector([1.773, 8.343]), 9.525)
print l1.intersection_with(l2)


[4.046x_1 + 2.836x_2 = 1.21] is parallel to [10.115x_1 + 7.09x_2 = 3.025]
None
Same? True
Vector: {2.226, -2.312}
[1.182x_1 + 5.562x_2 = 6.744] is parallel to [1.773x_1 + 8.343x_2 = 9.525]
None

In [8]:
%aimport plane

In [21]:
from plane import *

p1 = Plane(Vector([-0.412, 3.806, 0.728]), -3.46)
p2 = Plane(Vector([1.03, -9.515, -1.82]), 8.65)
print p1.is_parallel_to(p2)
print p1 == p2

p1 = Plane(Vector([2.611, 5.528, 0.283]), 4.6)
p2 = Plane(Vector([7.715, 8.306, 5.342]), 3.76)
print p1.is_parallel_to(p2)
print p1 == p2

p1 = Plane(Vector([-7.926, 8.625, -7.212]), -7.952)
p2 = Plane(Vector([-2.642, 2.875, -2.404]), -2.443)
print p1.is_parallel_to(p2)
print p1.__eq__(p2)


True
True
False
False
True
False